package com.dmp.onlinestore.model.dto;

//public class PersonBean implements Serializable {
public class PersonBean {
	private String firstName;
	private String lastName;
	private String middleName;
	private char gender;
	private int id;
	
	// Zero-arg constructor to satisfy beans requirement.
	public PersonBean () {
	}
	
	// Convenience constructor to instantiate a bean quickly.
	public PersonBean (int id, String firstName, String middleName, String lastName) {
		setId(id);
		setFirstName(firstName);
		setLastName(lastName);
		setMiddleName(middleName);
		setGender('M');
	}
	// Convenience constructor to instantiate a bean quickly.
	public PersonBean (String firstName, String middleName, String lastName) {
		setId(-1);
		setFirstName(firstName);
		setLastName(lastName);
		setMiddleName(middleName);
		setGender('M');
	}
	
	public String getFirstName() {
		return firstName;
	}
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	public String getLastName() {
		return lastName;
	}
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	public String getMiddleName() {
		return middleName;
	}
	public void setMiddleName(String middleName) {
		this.middleName = middleName;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public char getGender() {
		return gender;
	}
	public void setGender(char gender) {
		this.gender = gender;
	}
	
	public String toString() {
		StringBuffer buf = new StringBuffer();
		if (! getLastName().equals("")) {
			// We have a non-null last name.
			buf.append(getLastName() + ", ");
		}
		if (!getFirstName().equals("")) {
			buf.append(getFirstName() + " ");
		}
		if (!getMiddleName().equals("")) {
			buf.append(getMiddleName());
		}
		String retStr = buf.toString();
		if (retStr.equals("")) {
			return ("Null-name");
		}
		else {
			return retStr;
		}
	}
	
}
